<?php
class NewsModel extends Model{
	private $table1 = 'news';
	private $table2 = 'news_info';
	/* public $viewFields = array(
	
			'news'=>array('*' ,'_as'=>'n' ),
	
			'news_info'=>array('*','_as'=>'ni','_on'=>'n.news_id=ni.news_id'),
	
	); */
	/*
	 * 获取指定字段
	 * @param $where $limit $order $field
	 */
	public function getListByField($where,$limit,$order,$field){
		return $this->table($this->table1.' n')->join($this->table2.' ni ON n.news_id=ni.news_id')->where($where)->field($field)->limit($limit)->order($order)->select();
		//echo $this->getLastSql();die;
	}
	
	public function getCount($where){
		$sql = "SELECT count(*) as c FROM ".$this->table1." WHERE ".$where;
		//echo $sql;die;
		$result= $this->query($sql);
		return $result[0]['c'];
	}
}